import { simpleTable2Sheet } from '@/utils/sheet'

export default {
  methods: {
    exportData (title) {
      const elTable = this.$refs.table
      let table = null
      if (elTable) {
        const thead = elTable.$el.querySelector('thead')
        const tbody = elTable.$el.querySelector('tbody')
        if (thead && tbody) {
          table = document.createElement('table')
          table.appendChild(thead.cloneNode(true))
          table.appendChild(tbody.cloneNode(true))
        }
      }
      if (table) {
        simpleTable2Sheet(table, title)
      }
    },
  }
}
